Page({
  data: {
    imagePath: '',//图片路径
    imageSize: 0,//图片大小
    avatarUrl: '',//用户头像
  },
  async chooseImage() {
    const res = await wx.chooseMedia({
      count: 1,
      mediaType: ['image']
    })
    console.log(res)
    if (res.tempFiles.length > 0) {
      this.setData({
        imagePath: res.tempFiles[0].tempFilePath,
        imageSize: res.tempFiles[0].size
      })
      wx.setStorageSync('imagePath', res.tempFiles[0].tempFilePath)
    }
  },
  onChooseAvatar(event: WechatMiniprogram.CustomEvent) {
    // console.log(event)
    this.setData({
      avatarUrl: event.detail.avatarUrl
    })
  },
  saveData() {
    wx.setStorageSync('list', ['鞋子', '毛衣'])
    wx.showToast({ title: '保存成功' })
  },
  getData() {
    const list = wx.getStorageSync('list')
    wx.showToast({ title: JSON.stringify(list), icon: 'none' })
  },
  removeData() {
    wx.removeStorageSync('list')
    wx.showToast({ title: '删除成功' })
  },
  clearData() {
    wx.clearStorageSync()
    wx.showToast({ title: '清空成功' })
  },
})